﻿@using Models
@using BLL
@model WorkflowInstance
@{
    ViewBag.Title = "预跑";
    Layout = "~/Views/Shared/_Master.cshtml";
}
<link href="@Url.Content("~/Content/jquery-ui-1.8.17.custom.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/jquery.wysiwyg.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function () {
        previewprocess();
    });
</script>
<h1>
    流程预跑</h1>
@using (Html.BeginForm())
{
    @Html.Hidden("workflowid", Model.WorkflowID);
    @Html.Hidden("workflowinstanceid", Model.ID);
    <fieldset class="preview-fieldset">
        <legend>流程发起人信息</legend>
        <table class="pre-table">
            <tr>
                <td>
                    <span>
                        <label>
                            发起人：</label><input id="app-applyer" name="app-applyer"  class="pre-applyer dyn-text" type="text" /></span>
                </td>
                <td>
                    <span>
                        <label>
                            发起人部门</label><input id="app-department" name="app-department" class="pre-department dyn-text" type="text" /></span>
                </td>
                <td>
                    <span>
                        <label>
                            代发人:</label><input id="app-proxy" name="app-proxy" class="pre-proxyapplyer dyn-text" type="text" /></span>
                </td>
                <td>
                    <span>
                        <label>
                            职级：</label><input id="app-level" name="app-level" class="dyn-text" type="text" /></span>
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset class="preview-fieldset">
        <legend>流程表单信息</legend>
        <table style="width: 100%">
            <tr>
                <td class="pre-formtd" colspan="4">
                    <ul class="pre-form">
                      @{
                          if (Model.Workflow.Fields != null)
                          {
                            foreach (var f in Model.Workflow.Fields)
                            {
                            <li id=@f.FieldName fieldwidth=@f.FieldWidth controltype="@f.ControlType" >
                                <div>
                                    <label class="dyn-fieldname" style="width: 100%">@f.FieldName</label>：
                                </div>
                                @if (f.ControlType == "text" || f.ControlType == "peoplefinder" || f.ControlType == "datepicker" || f.ControlType == "number")
                                {

                                    var fi = @FlowRun.GetFieldInstance(Model.ID, f.ID);
                                    <div>
                                        <input id=@f.FieldName name=@f.FieldName value=@FlowRun.GetFieldInstanceValue(Model.ID, f.ID)  type="text" class="dyn-text" />
                                    </div>
                                }
                                else if (f.ControlType == "singleselection")
                                { 
                                    <div class="singleselection">
                                        @if (f.OptionValue != null)
                                        {
                                            @Html.Hidden(f.FieldName, FlowRun.GetFieldInstance(Model.WorkflowID, f.ID).FieldValue);
                                            var options = f.OptionValue.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                                            foreach (var o in options)
                                            {
                                                <input type="radio"  value=@o  > @o </input>
                                            }
                                        }
                                    </div>

                                }
                                else if (f.ControlType == "multipleselection")
                                {
                                    <div class="multipleselection">
                                        @if (f.OptionValue != null)
                                        {
                                            @Html.Hidden(f.FieldName);
                                                                     var options = f.OptionValue.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);

                                                                     foreach (var o in options)
                                                                     {
                                            <input id=@f.FieldName type="checkbox" value=@o   >@o </input>
                                                                     }
                                        }
                                    </div>
                                }
                                else if (f.ControlType == "richtext")
                                {
                                   
                                    <textarea id=@f.FieldName name="@f.FieldName"></textarea>
                                  
                                }
                                else if (f.ControlType == "dropdownlist")
                                {
                                    <div>
                                        @if (f.OptionValue != null)
                                        {
                                            @Html.Hidden(f.FieldName);
                                            var options = f.OptionValue.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                                            <select id=@f.FieldName>
                                                <option>--请选择--</option>
                                                @foreach (var o in options)
                                                {
                                                    <option>@o</option>
                                                }
                                            </select>
                                        }
                                    </div>
                                }
                           </li>       
                        
                                 }
                            }
                        }
                    </ul>
                </td>
            </tr>
        </table>
    </fieldset>

    <fieldset class="preview-fieldset">
        <legend>审批结果</legend>
        <ul class='approveul'>
         @if (Model.ActivityInstances != null)
         {
             foreach (var a in Model.ActivityInstances)
             {
                  <li style="float:left">@a.Result</li>
             }
         }
        </ul>
        @{
       
        <center><span>当前审核人:@FlowRun.GetCurrentApprover(Model.ActivityInstances.FirstOrDefault())</span></center>
         }
        <center id="app-buttons">
           <input type="hidden" id="app-result" name="app-result" />
           <input type="submit" class="pre-approve" id="app-agree" value="同意" />
           <input type="submit" class="pre-approve" id="app-disagree" value="不同意" />
           <input  type="submit" class="pre-approve" id="app-continue" value="不同意但继续" />
           <input  type="submit" class="pre-approve" id="app-excution" value="执行" />
        </center>
    </fieldset>
}
